package com.example.graduatetest.activitys;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProviders;

import android.content.Intent;
import android.os.Bundle;

import com.example.graduatetest.R;
import com.example.graduatetest.bean.Classes;
import com.example.graduatetest.databinding.ActivityNoticeWriteBinding;
import com.example.graduatetest.view.model.CreateClassViewModel;
import com.example.graduatetest.view.model.NoticeWriteViewModel;

public class NoticeWriteActivity extends AppCompatActivity {
    private ActivityNoticeWriteBinding binding;
    private NoticeWriteViewModel viewModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notice_write);

        //隐藏ActionBar
        if(getSupportActionBar() != null){
            ActionBar actionBar = getSupportActionBar();
            actionBar.hide();
        }

        binding = DataBindingUtil.setContentView(this,R.layout.activity_notice_write);

        //接受Intent传来的数据
        Intent intent = getIntent();
        Classes ownClass = (Classes) intent.getSerializableExtra("classes");
        String type = intent.getStringExtra("type");

        //LiveData
        viewModel = ViewModelProviders.of(this).get(NoticeWriteViewModel.class);
        binding.setNoticeWriteViewModel(viewModel);
        binding.setLifecycleOwner(this);
        viewModel.init(this,binding,ownClass,type);
    }
}
